{extend name="common/base" /} {block name="body"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-tab layui-tab-brief">
                            <ul class="layui-tab-title">
                                <li class="layui-this">网站设置</li>
                                <li>上传设置</li>
                                <li>公共上传设置</li>
                                <li>系统设置</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-form" lwid100 iwid300 lay-filter="optionsWeb">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">网站名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="web_name" value="{$Think.config.web.web_name}"
                                                       autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">网站状态</label>
                                            <div class="layui-input-inline">
                                                {if $Think.config.web.web_status == 1}
                                                <input type="checkbox" checked lay-text="ON|OFF" name="web_status"
                                                       lay-skin="switch"> {else /}
                                                <input type="checkbox" lay-text="ON|OFF" name="web_status"
                                                       lay-skin="switch"> {/if}
                                            </div>
                                        </div>

                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <button class="layui-btn" lay-submit lay-filter="formOptionsWeb">保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-form" lwid150 iwid300 lay-filter="optionsUpload">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传文件大小限制</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="upload_file_size"
                                                       value="{$upload.upload_file_size}" autocomplete="off"
                                                       class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">单位：KB</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传文件后缀限制</label>
                                            <div class="layui-input-inline">
                                                <textarea class="layui-textarea" name="upload_file_ext">{$upload.upload_file_ext}</textarea>
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">英文逗号分隔</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传图片大小限制</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="upload_img_size"
                                                       value="{$upload.upload_img_size}" autocomplete="off"
                                                       class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">单位：KB</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传图片后缀限制</label>
                                            <div class="layui-input-inline">
                                                <textarea class="layui-textarea" name="upload_img_ext">{$upload.upload_img_ext}</textarea>
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">英文逗号分隔</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印状态</label>
                                            <div class="layui-input-inline">
                                                {if $upload['upload_img_water_status'] == 1}
                                                <input type="checkbox" checked lay-text="ON|OFF"
                                                       name="upload_img_water_status" lay-skin="switch"> {else /}
                                                <input type="checkbox" lay-text="ON|OFF" name="upload_img_water_status"
                                                       lay-skin="switch"> {/if}
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印上传</label>
                                            <div class="layui-input-inline">
                                                <div class="layui-upload">
                                                    <button id="water_img"
                                                            class="layui-btn layui-btn-primary layui-btn-sm"><i
                                                            class="layui-icon">&#xe67c;</i><span>上传图片</span></button>
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="water_img_preview"
                                                             src="{:cmf_get_image_url($upload.upload_img_water_img?:'/static/images/default.png')}">
                                                        <input name="upload_img_water_img" id="water_img_value"
                                                               type="hidden" class="layui-input" value="">
                                                        <a class="water_img_delete">清除</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印位置</label>
                                            <div class="layui-input-inline">
                                                <select name="upload_img_water_position">
                                                    <option value="1" {if $upload.upload_img_water_position==
                                                            1}selected{
                                                    /if}>标识左上角水印</option>
                                                    <option value="2" {if $upload.upload_img_water_position==
                                                            2}selected{
                                                    /if}>标识上居中水印</option>
                                                    <option value="3" {if $upload.upload_img_water_position==
                                                            3}selected{
                                                    /if}>标识右上角水印</option>
                                                    <option value="4" {if $upload.upload_img_water_position==
                                                            4}selected{
                                                    /if}>标识左居中水印</option>
                                                    <option value="5" {if $upload.upload_img_water_position==
                                                            5}selected{
                                                    /if}>标识居中水印</option>
                                                    <option value="6" {if $upload.upload_img_water_position==
                                                            6}selected{
                                                    /if}>标识右居中水印</option>
                                                    <option value="7" {if $upload.upload_img_water_position==
                                                            7}selected{
                                                    /if}>标识左下角水印</option>
                                                    <option value="8" {if $upload.upload_img_water_position==
                                                            8}selected{
                                                    /if}>标识下居中水印</option>
                                                    <option value="9" {if $upload.upload_img_water_position==
                                                            9}selected{
                                                    /if}>标识右下角水印</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印透明度</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="upload_img_water_alpha"
                                                       value="{$upload.upload_img_water_alpha}" autocomplete="off"
                                                       class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">值：0-100</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <button class="layui-btn" lay-submit lay-filter="formOptionsUpload">保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-form" lwid150 iwid300 lay-filter="optionsUpload">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">是否开启</label>
                                            <div class="layui-input-inline">
                                                {if isset($publicupload['upload_status']) &&
                                                $publicupload['upload_status'] == 1}
                                                <input type="checkbox" checked lay-text="ON|OFF" name="upload_status"
                                                       lay-skin="switch"> {else /}
                                                <input type="checkbox" lay-text="ON|OFF" name="upload_status"
                                                       lay-skin="switch"> {/if}
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传文件大小限制</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="upload_file_size"
                                                       value="{$publicupload.upload_file_size|default='200'}"
                                                       autocomplete="off" class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">单位：KB</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传文件后缀限制</label>
                                            <div class="layui-input-inline">
                                                <textarea class="layui-textarea" name="upload_file_ext">{$publicupload.upload_file_ext|default='doc'}</textarea>
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">英文逗号分隔</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传图片大小限制</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="upload_img_size"
                                                       value="{$publicupload.upload_img_size|default='200'}"
                                                       autocomplete="off" class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">单位：KB</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">上传图片后缀限制</label>
                                            <div class="layui-input-inline">
                                                <textarea class="layui-textarea" name="upload_img_ext">{$publicupload.upload_img_ext|default='jpg,png'}</textarea>
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">英文逗号分隔</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印状态</label>
                                            <div class="layui-input-inline">
                                                {if isset($publicupload['upload_img_water_status']) &&
                                                $publicupload['upload_img_water_status'] == 1}
                                                <input type="checkbox" checked lay-text="ON|OFF"
                                                       name="upload_img_water_status" lay-skin="switch"> {else /}
                                                <input type="checkbox" lay-text="ON|OFF" name="upload_img_water_status"
                                                       lay-skin="switch"> {/if}
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印上传</label>
                                            <div class="layui-input-inline">
                                                <div class="layui-upload">
                                                    <button id="public_water_img"
                                                            class="layui-btn layui-btn-primary layui-btn-sm"><i
                                                            class="layui-icon">&#xe67c;</i><span>上传图片</span></button>
                                                    <div class="layui-upload-list">
                                                        <img class="layui-upload-img" id="public_water_img_preview"
                                                             src="{:cmf_get_image_url($publicupload.upload_img_water_img?:'/static/images/default.png')}">
                                                        <input name="upload_img_water_img" id="public_water_img_value"
                                                               type="hidden" class="layui-input" value="">
                                                        <a class="public_water_img_delete">清除</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印位置</label>
                                            <div class="layui-input-inline">
                                                {php}
                                                if(!isset($publicupload['upload_img_water_position'])){
                                                $publicupload['upload_img_water_position'] = 1;
                                                }
                                                {/php}
                                                <select name="upload_img_water_position">
                                                    <option value="1" {if $publicupload.upload_img_water_position==
                                                            1}selected{
                                                    /if}>标识左上角水印</option>
                                                    <option value="2" {if $publicupload.upload_img_water_position==
                                                            2}selected{
                                                    /if}>标识上居中水印</option>
                                                    <option value="3" {if $publicupload.upload_img_water_position==
                                                            3}selected{
                                                    /if}>标识右上角水印</option>
                                                    <option value="4" {if $publicupload.upload_img_water_position==
                                                            4}selected{
                                                    /if}>标识左居中水印</option>
                                                    <option value="5" {if $publicupload.upload_img_water_position==
                                                            5}selected{
                                                    /if}>标识居中水印</option>
                                                    <option value="6" {if $publicupload.upload_img_water_position==
                                                            6}selected{
                                                    /if}>标识右居中水印</option>
                                                    <option value="7" {if $publicupload.upload_img_water_position==
                                                            7}selected{
                                                    /if}>标识左下角水印</option>
                                                    <option value="8" {if $publicupload.upload_img_water_position==
                                                            8}selected{
                                                    /if}>标识下居中水印</option>
                                                    <option value="9" {if $publicupload.upload_img_water_position==
                                                            9}selected{
                                                    /if}>标识右下角水印</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">水印透明度</label>
                                            <div class="layui-input-inline">
                                                <input type="number" name="upload_img_water_alpha"
                                                       value="{$publicupload.upload_img_water_alpha|default=''}"
                                                       autocomplete="off" class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">值：0-100</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <button class="layui-btn" lay-submit lay-filter="formOptionsOpenUpload">
                                                    保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-form" lwid150 iwid300 lay-filter="optionsSystem">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">默认首页</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="web_index"
                                                       value="{:config('system.web_index')}" autocomplete="off"
                                                       class="layui-input">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">重要信息，非专业人士勿动</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">CDN状态</label>
                                            <div class="layui-input-inline">
                                                {if config('system.cdn_status')}
                                                <input type="checkbox" checked lay-text="ON|OFF" name="cdn_status"
                                                       lay-skin="switch"> {else /}
                                                <input type="checkbox" lay-text="ON|OFF" name="cdn_status"
                                                       lay-skin="switch"> {/if}
                                            </div>
                                            <div class="layui-form-mid layui-word-aux">静态文件CDN，需要上传静态文件到CDN</div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">CDN地址</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="cdn_url" value="{:config('system.cdn_url')}"
                                                       autocomplete="off" class="layui-input">
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-input-block">
                                                <button class="layui-btn" lay-submit lay-filter="formOptionsSystem">保存
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block} {block name="my_js"}
<script>
    layui.use(['element', 'admin', 'form'], function () {
        var form = layui.form,
            $ = layui.$,
            admin = layui.admin;
        form.render();
        form.on('submit(formOptionsWeb)', function (data) {
            if (data.field.web_status) {
                data.field.web_status = 1;
            } else {
                data.field.web_status = 0;
            }
            admin.ajax('admin/options/web', data.field);
        });
        form.on('submit(formOptionsUpload)', function (data) {
            if (data.field.upload_img_water_status) {
                data.field.upload_img_water_status = 1;
            } else {
                data.field.upload_img_water_status = 0;
            }
            admin.ajax('admin/options/upload', data.field);
        });
        form.on('submit(formOptionsOpenUpload)', function (data) {
            if (data.field.upload_img_water_status) {
                data.field.upload_img_water_status = 1;
            } else {
                data.field.upload_img_water_status = 0;
            }
            if (data.field.upload_status) {
                data.field.upload_status = 1;
            } else {
                data.field.upload_status = 0;
            }
            admin.ajax('admin/options/publicupload', data.field);
        });
        form.on('submit(formOptionsSystem)', function (data) {
            if (data.field.wx_open_status) {
                data.field.wx_open_status = 1;
            } else {
                data.field.wx_open_status = 0;
            }
            if (data.field.cdn_status) {
                data.field.cdn_status = 1;
            } else {
                data.field.cdn_status = 0;
            }
            admin.ajax('admin/options/system', data.field);
        });
        admin.imgUpload({
            elem: '#water_img',
            preview: '#water_img_preview',
            input: '#water_img_value'
        });
        admin.imgUpload({
            elem: '#public_water_img',
            preview: '#public_water_img_preview',
            input: '#public_water_img_value'
        });
        $('.water_img_delete').click(function () {
            $('#water_img_preview').attr('src', '/static/images/default.png');
            $('#water_img_value').val('');
        });
        $('.public_water_img_delete').click(function () {
            $('#public_water_img_preview').attr('src', '/static/images/default.png');
            $('#public_water_img_value').val('');
        });

    });
</script>
{/block}